package Song.Han.day05.demo02;

import java.util.Scanner;

/*
* 题目：
*     键盘输入一个字符串，并且统计其中哥哥字符出现的次数。
*     种类包括：大写字母、小写字母、数字、其他
* */
public class Demo07StringTest2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个字符串：");
        String input = sc.next();

        int countUpper = 0;
        int countLower = 0;
        int countNumber = 0;
        int countOther = 0;

        char[] chars = input.toCharArray();

        for (int i = 0; i < chars.length; i++) {
            char charPos = chars[i];//当前字符

            if('A' <= charPos && charPos <= 'Z'){
                countUpper++;
            }
            else if ('a' <= charPos && charPos <= 'z'){
                countLower++;
            }
            else if ('0' <= charPos && charPos <= '9'){
                countNumber++;
            }
            else countOther++;
        }

        System.out.println("大写字母有"+countUpper+"个");
        System.out.println("小写字母有"+countLower+"个");
        System.out.println("数字有"+countNumber+"个");
        System.out.println("其他有"+countOther+"个");

    }

}
